<?php
/**
 * Created by PhpStorm.
 * User: geyouwen
 * Date: 16/7/7
 * Time: 上午11:17
 */
namespace Backend\Controller;

use Think\Controller;

class CacheController extends BaseController
{

    //清理缓存
    public function index()
    {
        $this->display();
    }

    //ajax 清理缓存
    public function clear()
    {
        $path = CACHE_PATH;
        $type = I('type','site','trim');
        switch($type)
        {
            case 'site':
                $path .= 'Backend'; //模版解析缓存
                $other_path[]  = CACHE_PATH.'Data'; //数据缓存
                break;
            case 'template':
                $path .= 'Temp';
                break;
            case 'logs':
                $path .= 'Logs';
                break;
        }
        deleteAll($path);
        if(isset($other_path))
        {
            foreach($other_path as $k => $v)
            {
                deleteAll($v);
            }
        }
        $back = array('status' =>1, 'msg' => '缓存数据清理完毕！');
        $this->ajaxReturn($back);
    }
}